import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import Components from "unplugin-vue-components/vite";
import { AntDesignVueResolver } from "unplugin-vue-components/resolvers";
import AutoImport from "unplugin-auto-import/vite";
import projectConfig from "./projectConfig.js";
import postcssConfig from "./postcss.config.js";
// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    AutoImport({
      imports: ["vue", "vue-router", "pinia"],
      dts: "src/auto-imports.d.ts",
      resolvers: [AntDesignVueResolver()],
    }),
    Components({
      resolvers: [
        AntDesignVueResolver({
          importStyle: false, //
        }),
      ],
    }),
    // visualizer({
    //   open: true,
    // }),
  ],
  resolve: {
    alias: {
      ...projectConfig.alias,
    },
    extensions: ["*", ".vue", ".js", ".scss", ".sass", ".ts", ".json"],
  },
  css: {
    postcss: postcssConfig,
  },
  build: {
    assetsDir: "static",
    rollupOptions: {
      output: {
        chunkFileNames: "static/js/[name]-[hash].js",
        entryFileNames: "static/js/[name]-[hash].js",
        assetFileNames: "static/[ext]/[name]-[hash].[ext]",
      },
    },
  },
  server: {
    port: projectConfig.port || 3000,
    open: true,
    // host: projectConfig.host || "localhost",
    hmr: true,
    proxy: {
      ...projectConfig.proxy,
    },
  },
});
